home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_097 / splines / dlist.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  43 lines

  1. /* The routines in this file are copyright (c) 1987 by Helene (Lee) Taran.
  2.  * Permission is granted for use and free distribution as long as the
  3.  * original author's name is included with the code.
  4.  */
  5.  
  6. /*
  7.  *   This file defines a general purpose doubly-linked circluar list.
  8.  */
  9. #ifndef DLIST_H
  10. #define DLIST_H
  11.  
  12. #include <stdio.h>
  13.  
  14. typedef struct dlist {
  15.    void *contents;
  16.    struct dlist *next;
  17.    struct dlist *prev;
  18. } DLIST_ELEMENT, *DLISTPTR;
  19.  
  20. /* The first element in the list is a dummy record that
  21.  * contains the current length of the list
  22.  */
  23.  
  24. #ifndef TRUE
  25. #define TRUE 1
  26. #endif
  27.  
  28. #ifndef FALSE
  29. #define FALSE 0
  30. #endif
  31.  
  32. #define FIRST(list) ((list)->next)
  33. #define LAST(list) ((list)->prev)
  34. #define NEXT(element) ((element)->next)
  35. #define PREVIOUS(element) ((element)->prev)
  36. #define LENGTH(list) (*(int *)((list)->contents))
  37. #define ISEMPTY(list) (LENGTH(list) == 0)
  38. #define INSERT_FIRST(element,list) Insert_Before(FIRST(list),element,list)
  39. #define INSERT_LAST(element,list)  Insert_After(LAST(list),element,list)
  40. #define MOVE_FIRST(x,y)  INSERT_FIRST( Remove_Element( FIRST((x)),(x)), (y))
  41. #define MOVE_LAST(x,y)   INSERT_LAST( Remove_Element(  LAST((x)),(x)), (y))
  42. #endif
  43.